package com.sto.stoapp.listener;

import com.sto.stoapp.log.ExceptionLog;
import com.sto.stoapp.widget.BaseDialog;

import android.app.Activity;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

/**
 * 抽象RadioGroup监听
 * 
 * @author mgf
 * 
 */
public abstract class StoOnCheckedChangeListener implements
		OnCheckedChangeListener {

	private Activity activity;

	public StoOnCheckedChangeListener(Activity activity) {
		this.activity = activity;
	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		try {
			stOnCheckedChanged(group, checkedId);
		} catch (Exception e) {
			ExceptionLog.writeLog("onCheckedChanged", e.getMessage());
			final BaseDialog dialog = new BaseDialog(activity);
			dialog.setTitles(e.getMessage());
			dialog.show();
			dialog.getvCanncel().setVisibility(View.GONE);
			dialog.getvMessage().setVisibility(View.GONE);
			dialog.getvPresentation().setVisibility(View.GONE);
			dialog.setOnBackClickListener(new OnBackClickListener() {
			
				@Override
				public void onBackClickListener(boolean res) {
					// TODO Auto-generated method stub
					dialog.dismiss();
				}
			});
		}
	}

	/**
	 * 抽象监听
	 * 
	 * @param group
	 * @param checkedId
	 */
	public abstract void stOnCheckedChanged(RadioGroup group, int checkedId);
}
